package cn.net.yugu.doraemon.springweb.util;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author wanghongli
 * @date 2023/3/21 14:51
 * @description ServletUtil
 **/
@Slf4j
public class ServletUtil {
    public static String getServletInputStream2String(HttpServletRequest httpServletRequest) {
        String content = "";
        try {
            content = IOUtils.toString(httpServletRequest.getInputStream(), StandardCharsets.UTF_8);
        } catch (IOException e) {
            log.error(e.getMessage());
        }
        return content;
    }
}
